<?php

/*

Bidding (auctions_bid.php)

*/

$page_title = "Bidding";
$rank_check = 1;
include "header.inc.php";

print "$openHTML";

$findAuction = fetch("SELECT * FROM auctions2 WHERE id = '$id' AND game = '$game'");
$findItem = fetch("SELECT * FROM items2 WHERE item_name = '$findAuction[item_name]' AND game = '$game'");

if (!$findAuction[high_bidder])
{
	$findAuction[high_bidder] = "<i>no one</i>";
}
else
{
	$findAuction[high_bidder] = "<a href=user_profile.php?game=$game&user=$findAuction[high_bidder]>$findAuction[high_bidder]</a>";
}

$time_left = $findAuction[end_time] - $timestamp;
$seconds = $time_left % 60;
$minutes = round(($time_left / 60) % 60);
$hours = round(($time_left / 60) / 60) % 60 - 1;
$time_left = "$seconds Sec.";
if ($minutes >= 1) { $time_left = "$minutes Min. $time_left"; }
if ($hours >= 1) { $time_left = "$hours Hours $time_left"; }

if ($findAuction[buy_now_price] > 0)
{
	$buyNow = "<br><font size=-1><a href=auctions_buynow.php?game=$game&id=$findAuction[id]>Buy now for $findAuction[buy_now_price] $pointsVar!</a></font>";
}
else
{
	$buyNow = "";
}

$nextBid = $findAuction[high_bid] + $findAuction[min_increment];

ECHO <<<END

<p align=center><a href=auctions.php?game=$game&page=search&search_by=my_auctions>My Auctions</a> | <a href=auctions_create.php?game=$game>Create Auction</a> | <a href=auctions.php?game=$game>Auction Home</a></p>

<P><FORM ACTION="auctions.php?game=$game&page=search" METHOD=POST>
   <CENTER><TABLE BGCOLOR="$tableOutline" CELLSPACING=1 CELLPADDING=0 WIDTH=400>
      <TR BGCOLOR="$topAndBottomBG">
         <TD HEIGHT=45>
            <CENTER><FONT SIZE="+3" COLOR="$topAndBottomText"><B>--Auctions--</B></FONT></CENTER>
         </TD>
      </TR>
      <TR BGCOLOR="$maincellColor">
         <TD HEIGHT=25>
            <CENTER><FONT SIZE="-1">Order by: </FONT><A HREF="auctions.php?game=$game&page=search&orderby=ending_soonest"><FONT SIZE="-1">Ending Soonest</FONT></A><FONT SIZE="-1">, </FONT><A HREF="auctions.php?game=$game&page=search&orderby=ending_last"><FONT SIZE="-1">Ending Last</FONT></A><FONT SIZE="-1">, </FONT><A HREF="auctions.php?game=$game&page=search&orderby=highest_price"><FONT SIZE="-1">Highest
            Price</FONT></A><FONT SIZE="-1">, </FONT><A HREF="auctions.php?game=$game&page=search&orderby=lowest_price"><FONT SIZE="-1">Lowest
            Price</FONT></A></CENTER>
         </TD>
      </TR>
      <TR BGCOLOR="$reallyLight">
         <TD HEIGHT=25>
            <CENTER><FONT SIZE="-1">Search where:<SELECT NAME=search_by>
               <OPTION VALUE="item_name_contains">Item Name Contains
               <OPTION VALUE="item_name_is">Item Name IS
               <OPTION VALUE="owner">Owner IS
            </SELECT></FONT></CENTER>
         </TD>
      </TR>
      <TR BGCOLOR="$maincellColor">
         <TD HEIGHT=25>
            <CENTER><FONT SIZE="-1">The words:
            <INPUT TYPE=text NAME=search_for VALUE="" SIZE=22></FONT></CENTER>
         </TD>
      </TR>
      <TR BGCOLOR="$middleBG">
         <TD>
            <CENTER><INPUT TYPE=submit NAME=Submit VALUE="Search Auctions!"></CENTER>
         </TD>
      </TR>
   </TABLE>
   </CENTER>
</FORM></P>

<CENTER><TABLE BGCOLOR="$tableOutline" CELLSPACING=1 CELLPADDING=0 WIDTH=275>
   <TR BGCOLOR="$topAndBottomBG">
      <TD COLSPAN=2 WIDTH="100%" HEIGHT=50>
         <CENTER><FONT SIZE="+2" COLOR="$topAndBottomText">--Bidding--</FONT></CENTER>
      </TD>
   </TR>
   <TR BGCOLOR="$maincellColor">
      <TD COLSPAN=2 WIDTH="100%" HEIGHT=90>
         <CENTER><img src=images/user_images/opg_$game/items/item_$findItem[id].gif><BR>
         <B>$findAuction[item_name]<br>$time_left</B></CENTER>
      </TD>
   </TR>
   <TR BGCOLOR="$reallyLight">
      <TD COLSPAN=2 WIDTH="100%" HEIGHT=25>
         <CENTER><FONT SIZE="-1">The high bid is $findAuction[high_bid] $pointsVar, by
         $findAuction[high_bidder].$buyNow</FONT></CENTER>
      </TD>
   </TR>
   <TR>
      <TD COLSPAN=2 WIDTH="100%" HEIGHT=25 BGCOLOR="$maincellColor">
         <CENTER><FONT SIZE="-1"><form action=auctions_bid.pro.php?game=$game&id=$id method=post>I would like to bid
         <INPUT TYPE=text NAME=bid_value VALUE="$nextBid" SIZE=12>
         $pointsVar.</FONT></CENTER>
      </TD>
   </TR>
   <TR>
      <TD COLSPAN=2 WIDTH="100%" HEIGHT=25 BGCOLOR="$middleBG">
         <CENTER><B><INPUT TYPE=submit NAME=Submit VALUE="Bid!!"></form></B></CENTER>
      </TD>
   </TR>
</TABLE>
</CENTER>

END;

print $closeHTML;

?>